server {

  listen        3263;
  server_name   localhost;
  access_log    /var/log/nginx/host.access.log;
  error_log /var/log/nginx/host.error.log;

  root   /usr/share/nginx/html;
  index  index.html index.htm;

  location ~ .*remoteEntry.js$ {
      expires -1;
      add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
  }

  location ~* \.(?:manifest|appcache|html?|xml|json)$ {
     expires -1;
   }

  location ~* \.(?:css|js)$ {
     try_files $uri =404;
     expires 1y;
     access_log off;
     add_header Cache-Control "public";
   }

  # Any route containing a file extension (e.g. /devicesfile.js)
  location ~ ^.+\..+$ {
    try_files $uri  =404;
  }

  location / {
      root /usr/share/nginx/html;
      index index.html;
      autoindex on;
      set $fallback_file /index.html;
      if ($http_accept !~ text/html) {
          set $fallback_file /null;
      }
#       if ($uri ~ /$) {
#           set $fallback_file /null;
#       }
      try_files $uri $fallback_file;

      if ($request_method = 'OPTIONS') {
          add_header 'Access-Control-Allow-Origin: $http_origin');
          add_header 'Access-Control-Allow-Origin: GET, POST, DELETE, PUT, PATCH, OPTIONS');
          add_header 'Access-Control-Allow-Credentials: true');
          add_header 'Vary: Origin');

      }

       add_header 'Access-Control-Allow-Origin' "$http_origin" always;
       add_header 'Access-Control-Allow-Credentials' 'true' always;
       add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, PATCH, DELETE, OPTIONS' always;
       add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;

  }
}
